<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>


    <script>

        var arr = [1,1,1,2,1,2,1,2,34,5,3,3,5] ;


        // 对象的属性具有唯一性
        var obj = {} ;

        // obj.name = 'cc';

        // 把数组中的值当做对象的键名和键值
        // {1:1,2:2,31:31}
        for(var i = 0 ; i < arr.length ; i++) {
            obj[arr[i]] = arr[i] ;
        }

        console.log(obj);

        // 对象的键名，存入新的数组
        // [1,2,31]
        var arr2 = [] ;
        // 遍历对象
        for(var key in obj) {
            arr2.push(key - 0);
        }
        console.log(arr2);







    </script>
    
</body>
</html>